package com.niiwoo.civet.account.service.local.fundsFreeze;

import com.alibaba.fastjson.JSON;
import com.niiwoo.civet.account.constant.MQConstant;
import com.niiwoo.civet.account.dao.entity.AccountBase;
import com.niiwoo.civet.account.dao.entity.FundsFreezeOrder;
import com.niiwoo.civet.account.dao.entity.FundsUnfreezeOrder;
import com.niiwoo.civet.account.dao.entity.WithholdOrder;
import com.niiwoo.civet.account.dao.mapper.AccountBaseMapperExt;
import com.niiwoo.civet.account.dto.request.FundsFreezeOrderApplyRequestDTO;
import com.niiwoo.civet.account.dto.request.FundsUnfreezeOrderApplyRequestDTO;
import com.niiwoo.civet.account.dto.response.FundsFreezeOrderApplyResponseDTO;
import com.niiwoo.civet.account.dto.response.FundsFreezeOrderResponseDTO;
import com.niiwoo.civet.account.dto.response.FundsUnfreezeOrderApplyResponseDTO;
import com.niiwoo.civet.account.dto.response.FundsUnfreezeOrderResponseDTO;
import com.niiwoo.civet.account.enums.*;
import com.niiwoo.tripod.lanmao.component.LanMaoDirectService;
import com.niiwoo.tripod.lanmao.component.LanMaoSequence;
import com.niiwoo.tripod.lanmao.enums.TradeQueryTypeEnum;
import com.niiwoo.tripod.lanmao.request.FreezeRequest;
import com.niiwoo.tripod.lanmao.request.QueryTransactionRequest;
import com.niiwoo.tripod.lanmao.request.UnfreezeRequest;
import com.niiwoo.tripod.lanmao.response.LanMaoResponse;
import com.niiwoo.tripod.lanmao.response.QueryFreezeResponse;
import com.niiwoo.tripod.lanmao.response.QueryUnfreezeResponse;
import com.niiwoo.tripod.provider.exception.BizException;
import lombok.extern.slf4j.Slf4j;
import org.joda.time.DateTime;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;

/**
 * @Author Jaylin
 * @Date 2018-04-23
 * @Descript 资金冻结localService
 */
@Service
@Slf4j
public class FundsFreezeLocalService {

    @Autowired
    private FundsFreezeOrderService freezeOrderService;
    @Autowired
    private FundsUnfreezeOrderService unfreezeOrderService;
    @Autowired
    private LanMaoDirectService lanMaoDirectService;
    @Autowired
    private FundsFreezeTransactionService transactionService;
    @Autowired
    private RabbitTemplate rabbitTemplate;


    /**
     * 申请冻结接口
     *
     * @param applyRequestDTO
     * @return
     */
    public FundsFreezeOrderApplyResponseDTO applyFundsFreezeOrder(FundsFreezeOrderApplyRequestDTO applyRequestDTO) {
        if (Objects.isNull(applyRequestDTO)) {
            throw new BizException("ACC7006");
        }

        if (Objects.isNull(applyRequestDTO.getOrderId())) {
            throw new BizException("ACC7007");
        }

        if (Objects.isNull(applyRequestDTO.getFundsOrderTypeEnum())) {
            throw new BizException("ACC7008");
        }

        if (Objects.isNull(applyRequestDTO.getAmount()) || applyRequestDTO.getAmount().compareTo(BigDecimal.ZERO) < 0) {
            throw new BizException("ACC7009");
        }

        log.info("资金冻结接口,请求参数:" + JSON.toJSONString(applyRequestDTO));

        FundsFreezeOrderApplyResponseDTO applyResponseDTO = new FundsFreezeOrderApplyResponseDTO();

        FundsFreezeOrder targetOrder = freezeOrderService.queryFreezeOrderByOrderId(applyRequestDTO.getOrderId(), applyRequestDTO.getFundsOrderTypeEnum().getType());
        if (Objects.nonNull(targetOrder)) {
            log.info("资金冻结接口,订单请求重复,返回订单对象,订单信息:", JSON.toJSONString(targetOrder));
            applyResponseDTO.setRequestNo(targetOrder.getRequestNo());
            applyResponseDTO.setStatus(targetOrder.getStatus());
            return applyResponseDTO;
        }

        FundsFreezeOrder freezeOrder = freezeOrderService.applyFundsFreezeOrder(applyRequestDTO);
        applyResponseDTO.setRequestNo(freezeOrder.getRequestNo());

        FreezeRequest request = new FreezeRequest();
        request.setRequestNo(freezeOrder.getRequestNo());
        request.setAmount(applyRequestDTO.getAmount());
        request.setPlatformUserNo(freezeOrder.getPlatformUserNo());

        try {
            log.info("资金冻结接口,请求懒猫信息:", JSON.toJSONString(request));
            CompletableFuture<LanMaoResponse> future = lanMaoDirectService.freeze(request);
            LanMaoResponse lanMaoResponse = future.get();
            log.info("资金冻结接口,懒猫响应结果信息:", JSON.toJSONString(lanMaoResponse));
            if (lanMaoResponse.isSuccess()) {
                transactionService.dealFreezeOrderSuccess(freezeOrder.getId());
                applyResponseDTO.setStatus(FundsFreezeOrderStatusEnum.STATUS_SUCCESS.getStatus());
            } else {
                if ("100001".equals(lanMaoResponse.getErrorCode()) || "100003".equals(lanMaoResponse.getErrorCode())) {
                    applyResponseDTO.setStatus(FundsFreezeOrderStatusEnum.STATUS_DEAL.getStatus());
                } else {
                    transactionService.dealFreezeOrderFail(freezeOrder.getId(), lanMaoResponse.getErrorCode(), lanMaoResponse.getErrorMessage());
                    applyResponseDTO.setStatus(FundsFreezeOrderStatusEnum.STATUS_FAIL.getStatus());
                }
            }

        } catch (Exception e) {
            log.error("资金冻结异常", e);
            applyResponseDTO.setStatus(FundsFreezeOrderStatusEnum.STATUS_DEAL.getStatus());
        }

        return applyResponseDTO;
    }

    /**
     * 资金解冻接口
     *
     * @param applyRequestDTO
     * @return
     */
    public FundsUnfreezeOrderApplyResponseDTO fundsUnfreezeOrder(FundsUnfreezeOrderApplyRequestDTO applyRequestDTO) {
        if (Objects.isNull(applyRequestDTO)) {
            throw new BizException("ACC7006");
        }

        if (Objects.isNull(applyRequestDTO.getOrderId())) {
            throw new BizException("ACC7007");
        }

        if (Objects.isNull(applyRequestDTO.getFundsOrderTypeEnum())) {
            throw new BizException("ACC7008");
        }

        if (Objects.isNull(applyRequestDTO.getAmount()) || applyRequestDTO.getAmount().compareTo(BigDecimal.ZERO) < 0) {
            throw new BizException("ACC7009");
        }

        if (Objects.isNull(applyRequestDTO.getFreezeRequestNo())) {
            throw new BizException("ACC7010");
        }

        log.info("资金解冻接口,请求参数:" + JSON.toJSONString(applyRequestDTO));

        FundsFreezeOrder fundsFreezeOrder = freezeOrderService.queryFreezeOrderByRequestNo(applyRequestDTO.getFreezeRequestNo());
        if (Objects.isNull(fundsFreezeOrder)) {
            throw new BizException("ACC7003");
        }

        BigDecimal subAmount = fundsFreezeOrder.getAmount().subtract(fundsFreezeOrder.getUnfreezeAmount());
        if (subAmount.compareTo(applyRequestDTO.getAmount()) < 0) {
            throw new BizException("ACC7002");
        }

        FundsUnfreezeOrderApplyResponseDTO applyResponseDTO = new FundsUnfreezeOrderApplyResponseDTO();
        FundsUnfreezeOrder targetOrder = unfreezeOrderService.queryUnfreezeOrderByOrderId(applyRequestDTO.getOrderId(), applyRequestDTO.getFundsOrderTypeEnum().getType());
        if (Objects.nonNull(targetOrder)) {
            log.info("资金解冻接口,订单请求重复,返回订单对象,订单信息:", JSON.toJSONString(targetOrder));
            applyResponseDTO.setRequestNo(targetOrder.getRequestNo());
            applyResponseDTO.setStatus(targetOrder.getStatus());
            return applyResponseDTO;
        }

        FundsUnfreezeOrder unfreezeOrder = unfreezeOrderService.applyUnfreezeOrder(applyRequestDTO);
        applyResponseDTO.setRequestNo(unfreezeOrder.getRequestNo());

        UnfreezeRequest request = new UnfreezeRequest();
        request.setRequestNo(unfreezeOrder.getRequestNo());
        request.setOriginalFreezeRequestNo(applyRequestDTO.getFreezeRequestNo());
        request.setAmount(applyRequestDTO.getAmount());
        request.setPlatformUserNo(unfreezeOrder.getPlatformUserNo());

        try {
            log.info("资金解冻接口,请求懒猫信息:", JSON.toJSONString(request));
            CompletableFuture<LanMaoResponse> future = lanMaoDirectService.unfreeze(request);
            LanMaoResponse lanMaoResponse = future.get();
            log.info("资金解冻接口,懒猫响应结果信息:", JSON.toJSONString(lanMaoResponse));
            if (lanMaoResponse.isSuccess()) {
                transactionService.dealUnfreezeOrderSuccess(unfreezeOrder.getId());
                applyResponseDTO.setStatus(FundsFreezeOrderStatusEnum.STATUS_SUCCESS.getStatus());
            } else {
                if ("100001".equals(lanMaoResponse.getErrorCode()) || "100003".equals(lanMaoResponse.getErrorCode())) {
                    applyResponseDTO.setStatus(FundsFreezeOrderStatusEnum.STATUS_DEAL.getStatus());
                } else {
                    transactionService.dealUnfreezeOrderFail(unfreezeOrder.getId(), lanMaoResponse.getErrorCode(), lanMaoResponse.getErrorMessage());
                    applyResponseDTO.setStatus(FundsFreezeOrderStatusEnum.STATUS_FAIL.getStatus());
                }
            }

        } catch (Exception e) {
            log.error("资金冻结-解冻金额异常", e);
            applyResponseDTO.setStatus(FundsFreezeOrderStatusEnum.STATUS_DEAL.getStatus());
        }

        return applyResponseDTO;
    }

    /**
     * 查询冻结订单状态
     *
     * @param orderId
     * @param fundsOrderTypeEnum
     * @return
     */
    public FundsFreezeOrderResponseDTO queryFundsFreezeOrderResult(Long orderId, FundsOrderTypeEnum fundsOrderTypeEnum) {
        FundsFreezeOrder freezeOrder = freezeOrderService.queryFreezeOrderByOrderId(orderId, fundsOrderTypeEnum.getType());
        if (Objects.isNull(freezeOrder)) {
            return null;
        }

        FundsFreezeOrderResponseDTO responseDTO = new FundsFreezeOrderResponseDTO();
        //如果是处理中的订单则去存管方调用查询接口,执行业务处理
        if (FundsFreezeOrderStatusEnum.STATUS_DEAL.getStatus().equals(freezeOrder.getStatus())) {
            QueryTransactionRequest request = new QueryTransactionRequest();
            request.setPlatformUserNo(freezeOrder.getPlatformUserNo());
            request.setTransactionType(TradeQueryTypeEnum.FREEZE);
            request.setRequestNo(freezeOrder.getRequestNo());
            try {
                CompletableFuture<QueryFreezeResponse> future = lanMaoDirectService.queryFreeze(request);
                QueryFreezeResponse lanMaoResponse = future.get();
                log.info(String.format("查询资金冻结交易结果接口,响应结果信息:%s", JSON.toJSONString(lanMaoResponse)));
                //FREEZED 表示尚有冻结，UNFREEZED 表示已解冻，FAIL 表示失败，INIT 表示初始化，ERROR 表示异常
                if (lanMaoResponse.isSuccess()) {
                    String status = lanMaoResponse.getRecords().get(0).getStatus();
                    if (status.equals("FREEZED") || status.equals("UNFREEZED")) {
                        transactionService.dealFreezeOrderSuccess(freezeOrder.getId());
                    } else if (status.equals("FAIL")) {
                        transactionService.dealFreezeOrderFail(freezeOrder.getId(), lanMaoResponse.getErrorCode(), lanMaoResponse.getErrorMessage());
                    } else {
                        log.info("查询资金冻结交易结果接口,返回的状态值不在终态,不做任何处理");
                    }
                } else {
                    if ("100001".equals(lanMaoResponse.getErrorCode()) || "100003".equals(lanMaoResponse.getErrorCode())) {
                        //这两个返回码不处理业务
                    } else if ("100007".equals(lanMaoResponse.getErrorCode())) {
                        //判断时间是否大于30分钟
                        Date thirTyDateTime = new DateTime().minusMinutes(30).toDate();
                        if (freezeOrder.getCreateTime().before(thirTyDateTime)) {
                            transactionService.dealFreezeOrderFail(freezeOrder.getId(), lanMaoResponse.getErrorCode(), lanMaoResponse.getErrorMessage());
                        }
                    } else {
                        transactionService.dealFreezeOrderFail(freezeOrder.getId(), lanMaoResponse.getErrorCode(), lanMaoResponse.getErrorMessage());
                    }
                }

            } catch (Exception e) {
                log.error("执行处理资金冻结的订单出现异常", e);
                BeanUtils.copyProperties(freezeOrder, responseDTO);
                return responseDTO;
            }

            FundsFreezeOrder order = freezeOrderService.selectByPrimaryKey(freezeOrder.getId());
            BeanUtils.copyProperties(order, responseDTO);
        } else {
            BeanUtils.copyProperties(freezeOrder, responseDTO);
        }

        return responseDTO;
    }

    /**
     * 查询解冻订单状态
     *
     * @param orderId
     * @param fundsOrderTypeEnum
     * @return
     */
    public FundsUnfreezeOrderResponseDTO queryFundsUnfreezeOrderResult(Long orderId, FundsOrderTypeEnum fundsOrderTypeEnum) {
        FundsUnfreezeOrder unfreezeOrder = unfreezeOrderService.queryUnfreezeOrderByOrderId(orderId, fundsOrderTypeEnum.getType());
        if (Objects.isNull(unfreezeOrder)) {
            return null;
        }

        FundsUnfreezeOrderResponseDTO responseDTO = new FundsUnfreezeOrderResponseDTO();
        if (FundsFreezeOrderStatusEnum.STATUS_DEAL.getStatus().equals(unfreezeOrder.getStatus())) {
            QueryTransactionRequest request = new QueryTransactionRequest();
            request.setPlatformUserNo(unfreezeOrder.getPlatformUserNo());
            request.setTransactionType(TradeQueryTypeEnum.FREEZE);
            request.setRequestNo(unfreezeOrder.getRequestNo());
            try {
                log.info(String.format("查询资金解冻交易结果接口,请求参数:%s", JSON.toJSONString(request)));
                CompletableFuture<QueryUnfreezeResponse> future = lanMaoDirectService.queryUnfreeze(request);
                QueryUnfreezeResponse lanMaoResponse = future.get();
                log.info(String.format("查询资金解冻交易结果接口,响应结果信息:%s", JSON.toJSONString(lanMaoResponse)));
                //FREEZED 表示尚有冻结，UNFREEZED 表示已解冻，FAIL 表示失败，INIT 表示初始化，ERROR 表示异常
                if (lanMaoResponse.isSuccess()) {
                    String status = lanMaoResponse.getRecords().get(0).getStatus();
                    if (status.equals("SUCCESS")) {
                        transactionService.dealUnfreezeOrderSuccess(unfreezeOrder.getId());
                    }
                } else {
                    if ("100001".equals(lanMaoResponse.getErrorCode()) || "100003".equals(lanMaoResponse.getErrorCode())) {
                        //这两个返回码不处理业务
                    } else if ("100007".equals(lanMaoResponse.getErrorCode())) {
                        //判断时间是否大于30分钟
                        Date thirTyDateTime = new DateTime().minusMinutes(30).toDate();
                        if (unfreezeOrder.getCreateTime().before(thirTyDateTime)) {
                            transactionService.dealUnfreezeOrderFail(unfreezeOrder.getId(), lanMaoResponse.getErrorCode(), lanMaoResponse.getErrorMessage());
                        }
                    } else {
                        transactionService.dealUnfreezeOrderFail(unfreezeOrder.getId(), lanMaoResponse.getErrorCode(), lanMaoResponse.getErrorMessage());
                    }
                }

            } catch (Exception e) {
                log.error("执行处理资金解冻的订单出现异常", e);
                BeanUtils.copyProperties(unfreezeOrder, responseDTO);
                return responseDTO;
            }
            FundsUnfreezeOrder order = unfreezeOrderService.selectByPrimaryKey(unfreezeOrder.getId());
            BeanUtils.copyProperties(order, responseDTO);

        } else {
            BeanUtils.copyProperties(unfreezeOrder, responseDTO);
        }

        return responseDTO;
    }

    /**
     * job执行冻结处理中的订单
     */
    public void dealProcessingFreezeOrder() {
        log.info("jobProcessingFreezeOrder start");
        List<FundsFreezeOrder> listOrders = freezeOrderService.listFreezeOrderProcessing();
        Assert.notNull(listOrders, "冻结订单列表不能为空");
        log.info(String.format("资金冻结订单总数%s", listOrders.size()));

        //距离当前时间5分钟内的订单不处理
        Date maxDateTime = new DateTime().minusMinutes(5).toDate();
        List<FundsFreezeOrder> needProcessOrderList = listOrders.stream().filter(freezeOrder -> freezeOrder.getCreateTime().before(maxDateTime)).collect(Collectors.toList());
        int size = needProcessOrderList.size();
        log.info("距离当前时间5分钟内的订单不处理,资金冻结订单总数:", size);
        for (int i = 0; i < size; i++) {
            FundsFreezeOrder freezeOrder = needProcessOrderList.get(i);
            QueryTransactionRequest request = new QueryTransactionRequest();
            request.setPlatformUserNo(freezeOrder.getPlatformUserNo());
            request.setTransactionType(TradeQueryTypeEnum.FREEZE);
            request.setRequestNo(freezeOrder.getRequestNo());
            try {
                log.info(String.format("查询资金冻结交易结果接口,执行第%s条数据,请求参数:%s", (i + 1), JSON.toJSONString(request)));
                CompletableFuture<QueryFreezeResponse> future = lanMaoDirectService.queryFreeze(request);
                QueryFreezeResponse lanMaoResponse = future.get();
                log.info(String.format("查询资金冻结交易结果接口,执行第%s条数据,响应结果信息:%s", (i + 1), JSON.toJSONString(lanMaoResponse)));
                //FREEZED 表示尚有冻结，UNFREEZED 表示已解冻，FAIL 表示失败，INIT 表示初始化，ERROR 表示异常
                if (lanMaoResponse.isSuccess()) {
                    String status = lanMaoResponse.getRecords().get(0).getStatus();
                    if (status.equals("FREEZED") || status.equals("UNFREEZED")) {
                        transactionService.dealFreezeOrderSuccess(freezeOrder.getId());
                        this.sendFreezeOrderMQ(freezeOrder.getId());
                    } else if (status.equals("FAIL")) {
                        transactionService.dealFreezeOrderFail(freezeOrder.getId(), lanMaoResponse.getErrorCode(), lanMaoResponse.getErrorMessage());
                        this.sendFreezeOrderMQ(freezeOrder.getId());
                    } else {
                        log.info(String.format("查询资金冻结交易结果接口,执行第%s条数据,返回的状态值不在终态,不做任何处理", (i + 1)));
                    }
                } else {
                    if ("100001".equals(lanMaoResponse.getErrorCode()) || "100003".equals(lanMaoResponse.getErrorCode())) {
                        //这两个返回码不处理业务
                    } else if ("100007".equals(lanMaoResponse.getErrorCode())) {
                        //判断时间是否大于30分钟
                        Date thirTyDateTime = new DateTime().minusMinutes(30).toDate();
                        if (freezeOrder.getCreateTime().before(thirTyDateTime)) {
                            transactionService.dealFreezeOrderFail(freezeOrder.getId(), lanMaoResponse.getErrorCode(), lanMaoResponse.getErrorMessage());
                            this.sendFreezeOrderMQ(freezeOrder.getId());
                        }
                    } else {
                        transactionService.dealFreezeOrderFail(freezeOrder.getId(), lanMaoResponse.getErrorCode(), lanMaoResponse.getErrorMessage());
                        this.sendFreezeOrderMQ(freezeOrder.getId());
                    }
                }


            } catch (Exception e) {
                log.error("执行处理资金冻结的订单出现异常", e);
                continue;
            }
        }
    }

    private void sendFreezeOrderMQ(Long id) {
        FundsFreezeOrder order = freezeOrderService.selectByPrimaryKey(id);
        FundsFreezeOrderResponseDTO freezeOrderResponseDTO = new FundsFreezeOrderResponseDTO();
        BeanUtils.copyProperties(order, freezeOrderResponseDTO);
        rabbitTemplate.convertAndSend(MQConstant.FUNDSFREEZE_EXCHANGE, MQConstant.FUNDSFREEZE_DATA_ROUTING, freezeOrderResponseDTO);
    }

    /**
     * job执行处理中的解冻订单列表
     */
    public void dealProcessingUnfreezeOrder() {
        log.info("jobProcessingUnfreezeOrder start");
        List<FundsUnfreezeOrder> listOrders = unfreezeOrderService.listUnfreezeOrderProcessing();
        Assert.notNull(listOrders, "解冻订单列表不能为空");
        log.info(String.format("资金解冻订单总数%s", listOrders.size()));

        //距离当前时间5分钟内的订单不处理
        Date maxDateTime = new DateTime().minusMinutes(5).toDate();
        List<FundsUnfreezeOrder> needProcessOrderList = listOrders.stream().filter(unfreezeOrder -> unfreezeOrder.getCreateTime().before(maxDateTime)).collect(Collectors.toList());
        int size = needProcessOrderList.size();
        log.info("距离当前时间5分钟内的订单不处理,资金解冻订单总数:", size);
        for (int i = 0; i < size; i++) {
            FundsUnfreezeOrder unfreezeOrder = needProcessOrderList.get(i);
            QueryTransactionRequest request = new QueryTransactionRequest();
            request.setPlatformUserNo(unfreezeOrder.getPlatformUserNo());
            request.setTransactionType(TradeQueryTypeEnum.FREEZE);
            request.setRequestNo(unfreezeOrder.getRequestNo());
            try {
                log.info(String.format("查询资金解冻交易结果接口,执行第%s条数据,请求参数:%s", (i + 1), JSON.toJSONString(request)));
                CompletableFuture<QueryUnfreezeResponse> future = lanMaoDirectService.queryUnfreeze(request);
                QueryUnfreezeResponse lanMaoResponse = future.get();
                log.info(String.format("查询资金解冻交易结果接口,执行第%s条数据,响应结果信息:%s", (i + 1), JSON.toJSONString(lanMaoResponse)));
                //FREEZED 表示尚有冻结，UNFREEZED 表示已解冻，FAIL 表示失败，INIT 表示初始化，ERROR 表示异常
                if (lanMaoResponse.isSuccess()) {
                    String status = lanMaoResponse.getRecords().get(0).getStatus();
                    if (status.equals("SUCCESS")) {
                        transactionService.dealUnfreezeOrderSuccess(unfreezeOrder.getId());
                        this.sendUnfreezeOrderMQ(unfreezeOrder.getId());
                    }
                } else {
                    if ("100001".equals(lanMaoResponse.getErrorCode()) || "100003".equals(lanMaoResponse.getErrorCode())) {
                        //这两个返回码不处理业务
                    } else if ("100007".equals(lanMaoResponse.getErrorCode())) {
                        //判断时间是否大于30分钟
                        Date thirTyDateTime = new DateTime().minusMinutes(30).toDate();
                        if (unfreezeOrder.getCreateTime().before(thirTyDateTime)) {
                            transactionService.dealUnfreezeOrderFail(unfreezeOrder.getId(), lanMaoResponse.getErrorCode(), lanMaoResponse.getErrorMessage());
                            this.sendUnfreezeOrderMQ(unfreezeOrder.getId());
                        }
                    } else {
                        transactionService.dealUnfreezeOrderFail(unfreezeOrder.getId(), lanMaoResponse.getErrorCode(), lanMaoResponse.getErrorMessage());
                        this.sendUnfreezeOrderMQ(unfreezeOrder.getId());
                    }
                }


            } catch (Exception e) {
                log.error("执行处理资金解冻的订单出现异常", e);
                continue;
            }
        }
    }

    private void sendUnfreezeOrderMQ(Long id) {
        FundsUnfreezeOrder order = unfreezeOrderService.selectByPrimaryKey(id);
        FundsUnfreezeOrderResponseDTO unfreezeOrderResponseDTO = new FundsUnfreezeOrderResponseDTO();
        BeanUtils.copyProperties(order, unfreezeOrderResponseDTO);
        rabbitTemplate.convertAndSend(MQConstant.FUNDSUNFREEZE_EXCHANGE, MQConstant.FUNDSUNFREEZE_DATA_ROUTING, unfreezeOrderResponseDTO);
    }

}
